package com.redwood.report.adapter.bak;

import android.text.Spannable;
import android.text.SpannableStringBuilder;
import android.text.TextUtils;
import android.text.style.ForegroundColorSpan;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseMultiItemQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.chad.library.adapter.base.entity.MultiItemEntity;
import com.redwood.report.R;
import com.redwood.report.entity.bak.WxJiluInfo;
import com.redwood.report.util.Utils;

import java.util.List;

/**
 * 列表详细页面（未处理 处理中 已处理）
 *
 * Created by Supeng on 2018/8/23.
 */
//Caption been
public class ListItemAdapter extends BaseMultiItemQuickAdapter<MultiItemEntity,BaseViewHolder> {
    public static final int TYPE_LEVEL_1 = 0;
    public ListItemAdapter(List data) {
        super(data);
        addItemType(TYPE_LEVEL_1, R.layout.layout_baoxiu_detail_item);
    }
    @Override
    protected void convert(final BaseViewHolder holder, MultiItemEntity itemTemp) {
        switch (holder.getItemViewType()) {
            case TYPE_LEVEL_1:
               // holder.setText()
                WxJiluInfo.ListBean listBean= (WxJiluInfo.ListBean) itemTemp;
               holder.setText(R.id.tv_name,listBean.getAppName());
               holder.setText(R.id.tv_timer, Utils.timerParse(listBean.getAppTime()));
               holder.addOnClickListener(R.id.tv_name);
               TextView tvMiaoSu=holder.getView(R.id.tv_miaosu);
               setText(tvMiaoSu,listBean.getWxContent(),listBean.getImg());
                if(!TextUtils.isEmpty(listBean.getImg())){
                    holder.addOnClickListener(R.id.tv_miaosu);
                }
               break;
        }

    }
    public void setText(TextView tvCount,String context,String img) {
        String counStr="";
        if(!TextUtils.isEmpty(img)){
            String[] arrimgs=img.split("\\^");
            counStr=context + "照片("+arrimgs.length+")";
            SpannableStringBuilder style = new SpannableStringBuilder(counStr);
            style.setSpan(new ForegroundColorSpan(mContext.getResources().getColor(R.color.blueColorAppKey)), context.length(), counStr.length(), Spannable.SPAN_EXCLUSIVE_INCLUSIVE); //颜色
            tvCount.setText(style);
        }else{
            tvCount.setText(context);
        }

    }
}
